:BEGIN
REM @echo off
REM cmd file to import web Logs.
REM USAGE: webLogIMport <LogFilePath>
REM EXAMPLE webLogIMport C:\iislogs\
REM THe cmd file will import all .log files in the path specified, including subdirectories.

if "%1"=="" GOTO Erout

echo "#Fields: date time s-sitename s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status ">%1webDummy.log

FOR /F "tokens=*" %%a IN ('DIR /b /s %1*.log') DO SQLCMD -E -o "%%a.weblogimport.out" -i .\weblogimport.sql -v logfilename="%%a" bcpfmtfile="%CD%\weblogimport.fmt"

del %1webDummy*.* 

GOTO END 

:Erout
Echo USAGE: webLogIMport LogFilePath
Echo EXAMPLE webLogIMport C:\iislogs\

:END 